#pragma once
#include "loadUtils.h"

/**
 * @brief Struct for storing user data
 */
struct UserVars{
	int userID;
	char name[21];
	char userType[13];
	char user[6];
	char password[9];
};

/**
 * @brief keeps count of how many users there are, also used for memory reallocation
 */
extern int usercount;

/**
 * @brief Load user file into memory
 *
 * @param filename
 *
 * @param pata_ptr pointer to allocated memory
 *
 * @return return code
 */
int loadUsers(char const *filename,struct UserVars **data_ptr);

/**
 * @brief save userdata to file
 *
 * @param filename
 *
 * @param pata_ptr pointer to allocated memory
 *
 * @return return code
 */
int writeUsers(char const *filename,struct UserVars *data);

/**
 * @brief add a user to the vector, reallocates if needed
 *
 * @param pata_ptr pointer to allocated memory
 *
 * @param n
 */
void addUser(struct UserVars n,struct UserVars **data_ptr);

/**
 * @brief removes a user by index
 *
 * @param pata_ptr pointer to allocated memory
 *
 * @param index
 */
void rmUser(int index,struct UserVars **data_ptr);
